package co.edu.uniquindio.ingesis.ventana;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import co.edu.uniquindio.ingesis.logica.NumericQuestion;
import co.edu.uniquindio.ingesis.logica.QuestionDemo;

public class PanelNumericQuestion extends javax.swing.JPanel implements ActionListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel pregunta = new JLabel("califique de uno a cinco el servicio de transporte en armenia");
	private JTextField respuesta = new JTextField();
	private JButton check = new JButton("check");
	private NumericQuestion numQ = new NumericQuestion(pregunta.getText());
	
	private QuestionDemo miQuestionDemo= new QuestionDemo();

	public QuestionDemo getMiQuestionDemo() 
	{
		return miQuestionDemo;
	}

	public void setMiQuestionDemo(QuestionDemo miQuestionDemo) 
	{
		this.miQuestionDemo = miQuestionDemo;
	}

	public PanelNumericQuestion(VentanaPrincipal miVentana) 
	{
		super(new FlowLayout());
		numQ.setAnswer("3");
		check.addActionListener(this);
		add(pregunta, BorderLayout.NORTH);
		pregunta.setPreferredSize(new java.awt.Dimension(206, 16));
		add(respuesta, BorderLayout.CENTER);
		respuesta.setPreferredSize(new java.awt.Dimension(100, 16));
		add(check, BorderLayout.SOUTH);
	}

	@Override
	public void actionPerformed(ActionEvent e) 
	{
		if(e.getSource()==check)
		{
			String answer1= respuesta.getText();
			if(numQ.checkAnswer(answer1)== true)
			{
				JOptionPane.showMessageDialog(this, "la respuesta es correcta");
			}
			else
			{
				JOptionPane.showMessageDialog(this, "la respuesta es incorrecta");
			}
		}
	}

}
